<!DOCTYPE html>
<html>
    {include file="Widgets/head" /}
    
    <body class="gray-bg">
        <div class="wrapper wrapper-content animated fadeInUp ibox-content">
            <form action="{:url('Assets/doEditMain')}" method="post" class="form-horizontal">
                <input type="hidden" id="interest_rate_base" value="{$interest_rate}">
                <input type="hidden" name="id" value="{$assets['id']}">
                <div class="row">
                    <div class="col-sm-12 ">
                        <div class="ibox-title">
                            <h3>资产管理-编辑</h3>
                            <a class="pull-right" href="javascript:void(0);" onclick="window.history.back()">
                                <button class="btn btn-primary" type="button">返回</button>
                            </a>
                        </div> 
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-offset-1 col-sm-1">审核状态：未通过</div>
                    <div class="col-sm-2">审核时间：{if ($assets['check_time'])} {:date('Y-m-d H:i:s', $assets['check_time'])} {/if}</div>
                    <div class="col-sm-8 text-left">备注：{$assets['remarks']}</div>
                </div>
                <div class="hr-line-dashed"></div>
                <ul id="myTab" class="nav nav-tabs">
                    <li class="active"><a href="#home1" data-toggle="tab">基本信息</a></li>
                    <li><a href="#home2" data-toggle="tab">借款人信息</a></li>
                </ul>
                <div id="myTabContent" class="tab-content">
                    <div class="tab-pane fade in active" style="padding-top: 20px" id="home1">
                        <div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label" for="code">资产编号：</label>
                                <div class="col-sm-2 m-b-xs">
                                    <input type="text" id="code" name="code" value="{$assets['code']}" class="form-control input-s-sm inline" readonly>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="pull-left control-label col-sm-1" for="contract_time_start">合同起止时间：</label>
                                <div class="col-sm-2">
                                    <input type="date" id="contract_time_start" name="contract_time_start" 
                                           value="{:date('Y-m-d', $assets['contract_time_start'])}"
                                           class="form-control laydate-icon input-s-sm inline layer-date"
                                           onclick="laydate({istime: false, format: 'YYYY-MM-DD'})" required="required">
                                </div>
                                <label class="pull-left control-label col-sm-1" style="text-align:center;" for="contract_time_end">-</label>
                                <div class="col-sm-2">
                                    <input type="date" id="contract_time_end" name="contract_time_end" 
                                           value="{:date('Y-m-d', $assets['contract_time_end'])}"
                                           class="form-control laydate-icon input-s-sm inline layer-date"
                                           onclick="laydate({istime: false, format: 'YYYY-MM-DD'})" required="required">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label" for="duration">放款期限：</label>
                                <div class="input-group col-sm-2 m-b-xs">
                                    <select id="duration" name="duration" class="form-control input-s-sm inline" readonly
                                            onfocus="this.defaultIndex=this.selectedIndex;" onchange="this.selectedIndex=this.defaultIndex;">
                                        {foreach $term_list as $val}
                                        <option value="{$val}" {if ($assets['duration'] == $val)} selected {/if}>{$val}</option>
                                        {/foreach}
                                    </select>
                                    <span class="input-group-addon">天</span>
                                </div> 
                            </div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label" for="capital">资产本金：</label>
                                <div class="col-sm-2 m-b-xs">
                                    <input type="text" id="capital" name="capital" value="{$assets['capital']}" class="form-control input-s-sm inline" readonly>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label" for="repayment_type">还款方式：</label>
                                <div class="col-sm-2 m-b-xs">
                                    <select id="repayment_type" name="repayment_type" class="form-control input-s-sm inline" readonly
                                            onfocus="this.defaultIndex=this.selectedIndex;" onchange="this.selectedIndex=this.defaultIndex;">
                                        {foreach $repayment_type_list as $key => $val} 
                                        <option value="{$key}" {if ($assets['repayment_type'] == $key)} selected {/if}>{$val}</option>
                                        {/foreach}
                                    </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label" for="name">资产名称：</label>
                                <div class="col-sm-2">
                                    <input type="text" id="name" name="name" value="{$assets['name']}" class="form-control" required="required">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label" for="interest_rate">总成本利率：</label>
                                <div class="input-group col-sm-2 m-b-xs">
                                    <input type="number" id="interest_rate" name="interest_rate" value="{$assets['interest_rate']}" min="1" class="form-control input-s-sm inline" required="required">
                                    <span class="input-group-addon">%</span>
                                </div> 
                            </div>
                            <div class="form-group">
                                <label class="pull-left control-label col-sm-1" for="marketing_fee">营销费率：</label>
                                <div class="input-group col-sm-2 m-b-xs">
                                    <input type="number" id="marketing_fee" name="marketing_fee" value="{$assets['marketing_fee']}" min="0" step="0.01" class="form-control input-s-sm inline">
                                    <span class="input-group-addon">%</span>
                                </div> 
                            </div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label" for="service_remarks">营销备注：</label>
                                <div class="col-sm-2">
                                    <input type="text" id="service_remarks" name="service_remarks" value="{$assets['service_remarks']}" class="form-control">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label" for="service_amount_type">收取方式：</label>
                                <div class="col-sm-2 m-b-xs">
                                    <select id="service_amount_type" name="service_amount_type" class="form-control input-s-sm inline">
                                        <option value="1" {if ($assets['service_amount_type'] == 1)} selected {/if}>线上结算</option>
                                        <option value="2" {if ($assets['service_amount_type'] == 2)} selected {/if}>线下打款</option>
                                    </select>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <div class="col-sm-4 col-sm-offset-1">
                                    <button class="btn btn-primary" type="button" id="btn_tj">提交</button>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    {if ($assets['type'] == 1)}                    
                    <div class="tab-pane fade in"  style="padding-top: 20px" id="home2">
                        <div>
                            <div class="row">
                                <div class="col-sm-12">
                                    <table class="table table-bordered">
                                        <thead>
                                            <tr>
                                                <th>编号</th>
                                                <th>批次号</th>
                                                <th>姓名</th>
                                                <th>手机号</th>
                                                <th>身份证号</th>
                                                <th>车辆评估值</th>
                                                <th>放款比例</th>
                                                <th>放款评估金额</th>
                                                <th>放款期限（天）</th>
                                                <th>在贷余额</th>
                                                <th>放款金额</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            {foreach $detail as $key => $vo} 
                                            <tr>
                                                <td>{$key + 1}</td>
                                                <td>{$vo.batch_number}</td>
                                                <td>{$vo.real_name}</td>
                                                <td>{$vo.user_phone}</td>
                                                <td>{$vo.idcard}</td>
                                                <td>{$vo.car_price}</td>
                                                <td>{$vo.percent}</td>
                                                <td>{$vo.money}</td>
                                                <td>{$vo.duration}</td>
                                                <td>{$vo.borrow_money}</td>
                                                <td>{$vo.amount}</td>
                                            </tr>                                                
                                            {/foreach}
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-1">
                                <a href="{:url('Assets/editDetail',['id'=>$assets['id']])}" class="btn btn-primary">修改借款人</a>
                            </div>
                        </div>
                    </div>
                    {elseif ($assets['type'] == 2)/}
                    <div class="tab-pane fade in"  style="padding-top: 20px" id="home2">
                        <div>
                            <div class="row">
                                <div class="col-sm-12">
                                    <table class="table table-bordered">
                                        <thead>
                                            <tr>
                                                <th>编号</th>
                                                <th>批次号</th>
                                                <th>姓名</th>
                                                <th>手机号</th>
                                                <th>身份证号</th>
                                                <th>借款金额</th>
                                                <th>借款期限（天）</th>
                                                <th>放款期限（天）</th>
                                                <th>在贷余额</th>
                                                <th>放款金额</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            {foreach $detail as $key => $vo} 
                                            <tr>
                                                <td>{$key + 1}</td>
                                                <td>{$vo.batch_number}</td>
                                                <td>{$vo.real_name}</td>
                                                <td>{$vo.user_phone}</td>
                                                <td>{$vo.idcard}</td>
                                                <td>{$vo.money}</td>
                                                <td>{$vo.br_duration}</td>
                                                <td>{$vo.duration}</td>
                                                <td>{$vo.borrow_money}</td>
                                                <td>{$vo.amount}</td>
                                            </tr>                                                
                                            {/foreach}
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-1">
                                <a href="{:url('Assets/editDetail',['id'=>$assets['id']])}" class="btn btn-primary">修改借款人</a>
                            </div>
                        </div>
                    </div>
                    {else /}
                    <div class="tab-pane fade in"  style="padding-top: 20px" id="home2">
                        <div>
                            <div class="row">
                                <div class="col-sm-12">
                                    <table class="table table-bordered">
                                        <thead>
                                            <tr>
                                                <th>编号</th>
                                                <th>批次号</th>
                                                <th>企业名称</th>
                                                <th>联系人号码</th>
                                                <th>借款金额</th>
                                                <th>借款期限（天）</th>
                                                <th>放款期限（天）</th>
                                                <th>在贷余额</th>
                                                <th>放款金额</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            {foreach $detail as $key => $vo} 
                                            <tr>
                                                <td>{$key + 1}</td>
                                                <td>{$vo.batch_number}</td>
                                                <td>{$vo.company_name}</td>
                                                <td>{$vo.telephone}</td>
                                                <td>{$vo.money}</td>
                                                <td>{$vo.br_duration}</td>
                                                <td>{$vo.duration}</td>
                                                <td>{$vo.borrow_money}</td>
                                                <td>{$vo.amount}</td>
                                            </tr>                                                
                                            {/foreach}
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-1">
                                <a href="{:url('Assets/editDetail',['id'=>$assets['id']])}" class="btn btn-primary">修改借款人</a>
                            </div>
                        </div>
                    </div>
                    {/if}
                </div>
            </form>
        </div>
    </body>
    <script> 
        $(function () {
            //提交时
            $('#btn_tj').click(function () {
                //总成本利率判断
                var interest_rate_base = $("#interest_rate_base").val();
                var interest_rate = $("#interest_rate").val();
                if (parseFloat(interest_rate) < parseFloat(interest_rate_base)) {
                    alert('总成本利率不能低于默认值:'+interest_rate_base);
                    return false;
                }
                $('form').submit();
            });
        });
    </script>
</html>